<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiMessageMessageTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_message_message';

    /**
     * Run the migrations.
     * @table qii_message_message
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('ID');
            $table->unsignedInteger('sendtime')->default('0')->comment('提交时间');
            $table->unsignedTinyInteger('status')->default('0')->comment('状态 (0已删除,1正常)');
            $table->unsignedTinyInteger('is_show')->default('0')->comment('是否显示在前台(默认0：不显示)');
            $table->unsignedInteger('type_id')->default('1')->comment('类型');
            $table->unsignedTinyInteger('sticky')->nullable()->default('0')->comment('置顶 (0已删除,1正常)');
            $table->unsignedInteger('user_id')->nullable()->default('0')->comment('用户ID/匿名');
            $table->unsignedInteger('sortrank')->nullable()->default('0')->comment('排序');
            $table->unsignedInteger('time_d')->nullable()->default('0')->comment('回答时间');

            $table->index(["sendtime"], 'site_cate_sortrank');

            $table->index(["sticky", "sortrank"], 'sticky_sortrank');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
